Removes every item from target, leaving it empty (list_length(target) becomes 0). target's own declared capacity is unchanged - it can be filled again afterward.
list_clear(target)| Name | Type |
|---|---|
target | list |
Nothing.
Removes every item from target, leaving it empty (list_length(target) becomes 0). target's own declared capacity is unchanged, so it can be filled again afterward.
Useful for a fresh start - clearing a "picked up this room" list when the player enters a new room, say, rather than removing items one at a time.
/// @type {list<int>}
var scores = [10, 20, 30];
list_clear(scores);
var count = list_length(scores); // 0



The first capture's own "LENGTH: 3" is not a separate call the example above makes - it is what list_length(scores) would already answer at that point, shown alongside the list so the second capture reads as a real before/after, not just an empty list appearing from nowhere.
The vector's clear() - O(n) in how many items target held (each one's destructor runs), but never touches anything outside target itself.